package com.example.tyz1201.haha.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.tyz1201.haha.Model.Data;
import com.example.tyz1201.haha.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tyz1201 on 2016/4/14.
 */
public class ContentAdapter extends BaseAdapter {

    private List<String> list = new ArrayList<>();
    Context context;

    public ContentAdapter(List<String> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.item_content, parent, false);

        TextView tv_section = (TextView) view.findViewById(R.id.tv_section);
        tv_section.setText("第" + (position + 1) + "部分");

        TextView tv_icon_content = (TextView) view.findViewById(R.id.tv_icon_content);
        tv_icon_content.setText(list.get(position));

        return view;
    }
}
